package db_meta

import (
	db "engine/db"
	"gitee.com/ameise84/e3utils/str_conv"
	jsoniter "github.com/json-iterator/go"
	"servers/models/define"
)

func init() {
	db.RegisterTableMetaFactory(CfgBusinessGameRtpFactory)
}

func CfgBusinessGameRtpFactory() db.TableMeta {
	return &CfgBusinessGameRtp{}
}

type CfgBusinessGameRtp struct {
	CfgID      uint                  `json:"id" form:"id" gorm:"primarykey;column:id"`
	BusinessID define.BusinessIDType `json:"bid" form:"bid" gorm:"column:bid"`
	GameKindID define.GameKind       `json:"game_kind" form:"game_kind" gorm:"column:game_kind"`
	RTPLevel   define.RTPIndexType   `json:"rtp_level" form:"rtp_level" gorm:"column:rtp_level"`
	ExpectRTP  define.RTPValue       `json:"expect_rtp" form:"expect_rtp" gorm:"column:expect_rtp"`
}

func (v *CfgBusinessGameRtp) BaseTableName() string {
	return v.TableName()
}

func (v *CfgBusinessGameRtp) TableName() string {
	return "cfg_business_game_rtp"
}

func (v *CfgBusinessGameRtp) ID() string {
	return str_conv.ToString(v.CfgID)
}

func (v *CfgBusinessGameRtp) MarshalBinary() (data []byte, err error) {
	return jsoniter.Marshal(v)
}

func (v *CfgBusinessGameRtp) UnmarshalBinary(data []byte) error {
	return jsoniter.Unmarshal(data, v)
}
